package com.molichuxing.services.infrastructure.service.impl;

import java.util.List;
import java.util.Map;

import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.molichuxing.framework.dto.Paged;
import com.molichuxing.framework.utils.ObjectCastUtil;
import com.molichuxing.services.infrastructure.bean.GztDrivingLicenseNotifyLogBean;
import com.molichuxing.services.infrastructure.convertor.Convert;
import com.molichuxing.services.infrastructure.dao.GztDrivingLicenseNotifyLogMapper;
import com.molichuxing.services.infrastructure.dto.request.create.GztDrivingLicenseNotifyLogCreateDto;
import com.molichuxing.services.infrastructure.dto.response.GztDrivingLicenseNotifyLogDto;
import com.molichuxing.services.infrastructure.service.GztDrivingLicenseNotifyLogService;
/**
 * 
 * @author liyg
 * 国政通驾驶证服务实现类
 * 2019-09-20
 *
 */
@Service("gztDrivingLicenseNotifyLogService")
public class GztDrivingLicenseNotifyLogServiceImpl implements GztDrivingLicenseNotifyLogService{
	
	@Autowired
	private GztDrivingLicenseNotifyLogMapper  gztDrivingLicenseNotifyLogMapper;
	
	/**
	 * 保存
	 * @param createDto
	 * @return
	 */
	@Override
	public Integer create(GztDrivingLicenseNotifyLogCreateDto createDto) {
		GztDrivingLicenseNotifyLogBean bean=new GztDrivingLicenseNotifyLogBean();
		BeanUtils.copyProperties(createDto, bean);
		gztDrivingLicenseNotifyLogMapper.create(bean);
		return bean.getId();
	}
	
	
	/**
	 * 获取国政通驾驶证日志
	 * 
	 * @param map
	 *            参数
	 *key:idNumber
	 *            String 身份证号 非必填
	 *key:realName
	 *            String 用户真实姓名 非必填
	 *key:startTime
	 *            String 请求开始时间 非必填
	 *key:endTime
	 *            String 请求结束时间 非必填
	 *key:pageNum
	 *            Integer 当前页
	 *key:pageSize
	 *            Integer 每页显示条数
	 * @return
	 */
	@Override
	public Paged<GztDrivingLicenseNotifyLogDto> getGztDrivingLicenseNotifyLogList(Map<String, Object> map) {
		// 查询总条数
		long total = gztDrivingLicenseNotifyLogMapper.getGztDrivingLicenseNotifyLogListCount(map);
		if(total <= 0) {
			return null;
		}
		
		/*分页查询集合*/ 
		Integer pageNum = ObjectCastUtil.castInteger(map.get("pageNum"));
		Integer pageSize = ObjectCastUtil.castInteger(map.get("pageSize"));       
		List<GztDrivingLicenseNotifyLogBean>  list =  gztDrivingLicenseNotifyLogMapper.getGztDrivingLicenseNotifyLogList(map,pageNum,pageSize);
		List<GztDrivingLicenseNotifyLogDto> dtoList = Convert.toGztDrivingLicenseNotifyLogDto(list);
		Paged<GztDrivingLicenseNotifyLogDto> paged = new Paged<>(dtoList, total,pageSize);
		return paged;		
	}
}
